Skip to content

docs(adr): ADR-0102 — sandbox CPU-time budget + per-invocation sync WASM engine (#3275)#3299

Merged
os-zhuang merged 1 commit into
mainfrom
claude/nested-write-sandbox-timeout-muw13i
Jul 19, 2026
Merged

docs(adr): ADR-0102 — sandbox CPU-time budget + per-invocation sync WASM engine (#3275)#3299
os-zhuang merged 1 commit into
mainfrom
claude/nested-write-sandbox-timeout-muw13i

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Adds docs/adr/0102-sandbox-cpu-budget-and-engine-variant.md (status Proposed) — the decision record for the sandbox follow-up spec'd in #3275, front-loaded so the implementing agents for #3295 / #3296 / #3297 build against a written contract instead of re-deriving it.

What it records

  • D1 — budget = script CPU time, wall clock only as a ceiling. The existing knobs (body.timeoutMs, hookTimeoutMs/actionTimeoutMs, OS_SANDBOX_{HOOK,ACTION}_TIMEOUT_MS) keep names/defaults/precedence but change dimension: they meter VM-active slices; a separate 30s wall ceiling (aligned with the spec cap on ScriptBody.timeoutMs) bounds stuck host calls only. Kills the Flaky: nested-write.integration.test.ts sandbox hook exceeds the 250ms deadline on CI (Test Core) #3259 conflation where raising the knob for slow hosts also widened the CPU-DoS window, and stops billing nested hooks to their parent.
  • D2 — drop asyncify; per-invocation sync modules. Asyncify's only consumer died with the [P0] Hook sandbox crashes on nested cross-object writes — forces denormalized workarounds across templates #1867 deferred-promise + pump redesign; the sync variant (@jitl/quickjs-wasmfile-release-sync) is already installed. The per-invocation isolation model is stated as a normative invariant.
  • D3 — compile the WASM once, instantiate per invocation (newVariant(RELEASE_SYNC, { wasmModule }), verified in quickjs-emscripten@0.32.0); explicitly deferrable.
  • D4 — REJECTED: shared singleton module + per-invocation contexts — threat-model rationale (cross-tenant blast radius of a QuickJS heap bug in shared linear memory) + RSS ratchet, recorded so it is not re-proposed as an optimization.
  • Consequences (incl. the user-visible error-message change and the CI-floor removal path) and per-phase verification requirements.

Notes

Refs: #3275 (spec) · #3295 / #3296 / #3297 (phases) · #3259 / #3270 (history).

🤖 Generated with Claude Code


Generated by Claude Code

…ASM engine (#3275)

Records the two structural decisions spec'd in #3275, status Proposed:

- D1: the per-invocation sandbox budget charges script CPU time (VM-active
  slices), with wall clock demoted to a generous 30s ceiling that only bounds
  stuck host calls. Knob names/defaults/precedence unchanged; only the
  dimension changes — raising the CPU budget no longer trades away
  host-latency tolerance (the #3259 conflation).
- D2/D3: per-invocation *sync* WASM modules (asyncify's only consumer died
  with the #1867 deferred-promise redesign), instantiated from a
  once-compiled WebAssembly.Module; isolation invariant stated normatively.
- D4: shared singleton module + per-invocation contexts REJECTED on threat
  model (cross-tenant blast radius of a QuickJS heap bug in shared linear
  memory) and RSS ratchet — recorded so it is not re-proposed.

API facts verified against installed quickjs-emscripten@0.32.0 (see #3275).
Status flips to Accepted when Phase 1 (#3295) merges; D3 (#3297) deferrable.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011iJLjqToxNv1aYP3syQtRp
@vercel

vercel Bot commented Jul 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Building Building Preview, Comment Jul 19, 2026 4:16pm

Request Review

@github-actions github-actions Bot added size/s documentation Improvements or additions to documentation and removed size/s labels Jul 19, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review July 19, 2026 16:21
@os-zhuang
os-zhuang merged commit 52a2d74 into main Jul 19, 2026
14 of 15 checks passed
@os-zhuang
os-zhuang deleted the claude/nested-write-sandbox-timeout-muw13i branch July 19, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants